/*jslint node:true*/
'use strict';
var util = require('util');

//继承
function Base() {
    this.name = 'base';
    this.base = 1991;
    this.sayHello = function () {
        console.log('Hello ' + this.name);
    };
}
Base.prototype.showName = function () {
    console.log(this.name);
};
function Sub() {
    this.name = 'sub';
}
util.inherits(Sub, Base);
var objBase = new Base();
objBase.showName();
objBase.sayHello();
console.log(objBase);
var objSub = new Sub();
objSub.showName();
//objSub.sayHello();
console.log(objSub);

//对象转换字符串
function Person() {
    this.name = 'yyh';
    this.toString = function () {
        return this.name;
    };
}
var objPerson = new Person();
console.log(objPerson);
console.log(util.inspect(objPerson));
console.log(util.inspect(objPerson, true));
console.log(util.inspect(objPerson, true, 2, true));

//数组
console.log('[]:' + util.isArray([]));
//console.log('new Array:' + util.isArray(new Array));
console.log('{}:' + util.isArray({}));

//正则表达式
console.log('/some regexp/:' + util.isRegExp(/some regexp/));
console.log("new RegExp('another regexp'):" + util.isRegExp(new RegExp('another regexp')));
console.log('{}:' + util.isRegExp({}));

//日期
console.log('new Date():' + util.isDate(new Date()));
console.log('Date():' + util.isDate(Date()));
console.log('{}:' + util.isDate({}));

//错误
console.log('new Error():' + util.isError(new Error()));
console.log('new TypeError():' + util.isError(new TypeError()));
console.log("{name: 'Error', message: 'an error occurred'}:" + util.isError({name: 'Error', message: 'an error occurred'}));





